Operating on the semantic graph

All model configurations in Simantics are stored into a semantic graph database. Therefore it is the most primitive interface for accessing Simantics and in principle everything is doable with it, although sometimes with a great effort.

Understanding semantic graphs

The best tool for discovering how the model configuration is represented in the Simantics, is Graph debugger. It can be opened from Window/Show View/Other. Resources can be dragged to the debugger from the model browser.

The debugger shows the URI of the resource and all statements related to it.

Accessing resources

data Resource (Simantics/DB)

A resource is a node in a semantic graph.

resource :: String -> <ReadGraph> Resource (Simantics/DB)

Converts an absolute URI to a resource

relativeResource :: Resource -> String -> <ReadGraph> Resource (Simantics/DB)

Converts a relative URI to a resource starting from the given resource

possibleResource :: String -> <ReadGraph> Maybe Resource (Simantics/DB)

Converts an absolute URI to a resource or returns Nothing if there is no such resource.

uriOf :: Browsable a => a -> <ReadGraph> String (Simantics/DB)

Returns the URI of the given value.

currentModel :: <ReadGraph> Resource (Simantics/DB)

Gives the current active model.

(#) :: Resource -> Resource -> <ReadGraph> [Resource] (Simantics/DB)

subject # predicate returns all objects with the given subject and predicate.

possibleObject :: Resource -> Resource -> <ReadGraph> Maybe Resource (Simantics/DB)

If there is exactly one object with the given subject and predicate, possibleObject subject predicate returns it. Otherwise, it returns Nothing.

singleObject :: Resource -> Resource -> <ReadGraph> Resource (Simantics/DB)

Assumes that there is exactly one object with the given subject and predicate and returns it.

data Statement (Simantics/DB)

A statement is an edge in a semantic graph.

statements :: Resource -> Resource -> <ReadGraph> [Statement] (Simantics/DB)

statements subject predicate` returns all statements with the given subject and predicate.

singleStatement :: Resource -> Resource -> <ReadGraph> Statement (Simantics/DB)

Assumes that there is exactly one statement with the given subject and predicate and returns it.

Reading literal values

relatedValue :: Serializable a => Resource -> Resource -> <ReadGraph> a (Simantics/DB)

Reads the value of a literal that is an object with the given subject and predicate

nameOf :: Browsable a => a -> <ReadGraph> String (Simantics/DB)

Reads the name of the value.

Type queries

isInstanceOf :: Resource -> Resource -> <ReadGraph> Boolean (Simantics/DB)

isInstanceOf r t returns true, if r is an instance of t

isSubrelationOf :: Resource -> Resource -> <ReadGraph> Boolean (Simantics/DB)
isInheritedFrom :: Resource -> Resource -> <ReadGraph> Boolean (Simantics/DB)
singleTypeOf :: Resource -> Resource -> <ReadGraph> Resource (Simantics/DB)
possibleTypeOf :: Resource -> Resource -> <ReadGraph> Maybe Resource (Simantics/DB)

Transactions

The graph database can be accessed only in reading or writing transactions. The SCL console creates the transaction automatically if necessary, but sometimes it is necessary to control manually where the transactions are started.

syncRead :: (() -> <Proc,ReadGraph> a) -> <Proc> a (Simantics/DB)

Executes a read transaction and waits that it completes.

syncWrite :: (() -> <Proc,ReadGraph,WriteGraph> a) -> <Proc> a (Simantics/DB)

Executes a write transaction and waits that it completes.

asyncRead :: (() -> <Proc,ReadGraph> a) -> <Proc> () (Simantics/DB)

Begins a read transaction and immediately returns.

asyncWrite :: (() -> <Proc,ReadGraph,WriteGraph> a) -> <Proc> () (Simantics/DB)

Begins a write transaction and immediately returns.

Writing

newResource :: () -> <WriteGraph> Resource (Simantics/DB)

Creates a new resource.

claim :: Resource -> Resource -> Resource -> <WriteGraph> () (Simantics/DB)

Adds a statement to the semantic graph.

claimRelatedValue :: Serializable a => Resource -> Resource -> a -> <WriteGraph> () (Simantics/DB)

Sets the value of the literal that is an object with the given subject and predicate.

deny :: Resource -> Resource -> Resource -> <WriteGraph> () (Simantics/DB)

Removes a statement with the given subject, predicate and object

Entities

Didn't find the type class 'Entity'.

Searching

searchByType :: Resource -> Resource -> <ReadGraph> [Resource] (Simantics/Model)
searchByTypeShallow :: Resource -> Resource -> <ReadGraph> [Resource] (Simantics/Model)
searchByTypeAndName :: Resource -> Resource -> String -> <ReadGraph> [Resource] (Simantics/Model)
searchByTypeAndNameShallow :: Resource -> Resource -> String -> <ReadGraph> [Resource] (Simantics/Model)
searchByQuery :: Resource -> String -> <ReadGraph> [Resource] (Simantics/Model)
searchByQueryShallow :: Resource -> String -> <ReadGraph> [Resource] (Simantics/Model)
Simantics/Model/searchByTypeAndFilter